package com.itheima.常用API.递归;

public class 递归1 {
    public static void main(String[] args) {
        int n=100;
        long l1=sum(n);
        System.out.println("求和: ");
        System.out.println(l1);
        //阶乘
        long l2=jiCheng(3);
        System.out.println("阶乘: ");
        System.out.println(l2);
    }

    private static long jiCheng(int n) {
        if(n==1){
            return 1;
        }else{
            return jiCheng(n-1)*n;
        }
    }

    private static int sum(int i) {
        if(i==1){
            return 1;
        }else{
            return sum(i-1)+i;
        }
    }

}
